
onmessage = function(e) {
    console.log('Worker: Message received from main script', e);
    const info = JSON.parse(e.data[0])
    const voList = JSON.parse(e.data[1])
    const historyList = JSON.parse(e.data[2])
    const suggesList = JSON.parse(e.data[3])
    let suggList = suggesList
    if (
        !suggesList.length &&
        voList &&
        voList.length
      ) {
        suggList = voList
          .filter(v => v.productModel)
          .map(v => {
            const Vbrand = v.extVoList
            const params = {
              productModel: v.productModel,
              brand: Vbrand.find(l => {
                if (suggesList.find(n => n.brand === l.brand)) return l
              })?.brand,
              quotation: Vbrand.find(l => {
                if (suggesList.find(n => n.brand === l.brand)) return l
              })?.quotation,
              tax: Vbrand.find(l => {
                if (suggesList.find(n => n.brand === l.brand)) return l
              })?.tax
            }
            return params
          })
      }
    const data = {
        ...info,
        fileList:info.sysAttachFiles,
        voList
    }
    postMessage(JSON.stringify({data, historyList, suggList}));
}